<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>


<html:html>
<head>
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/stkissue2.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/stkissue/stkissue.css" />	
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/sampleForm.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/me.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/help/help.css" />
<script type="text/javascript" >
function returnToMainForm(lineNumber, itemOffset) {
	
	var	docNo	= 	document.getElementById("docNo"+itemOffset).innerHTML;
			
	opener.document.getElementById("docNo"+lineNumber).value = docNo;							
			
	window.close(); 
}
function colorOver() {
	
}
</script>

<style>

.odd{background-color :#fFA700; }
.even{background-color:#fFA700; }

.menu-over{background-color:#64b1ff;}

</style>

<script type="text/javascript" >

function modalWinItem(aa) {
	if (window.showModalDialog) {		
		window.showModalDialog(aa,"name","dialogTop:100px;dialogWidth:450px;dialogHeight:350px;center:yes");
	} else {		
		window.open(aa,'name','height=350,width=100,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
	}
}

var itemSelected = '';
function barcodeSelected(i) {
	
	var item = "'"+document.getElementById('cb'+i).value+"'";

	document.getElementById('r'+i).style.backgroundColor = "#0df00";
	
	if( document.getElementById('cb'+i).checked == true) {
		itemSelected = itemSelected + item +",";
	}else {
		itemSelected = itemSelected.replace(item+',',"");
	}
	
	if(itemSelected.length>0)  {
		document.getElementById('genBarcode').disabled = false;
	}else {
		document.getElementById('genBarcode').disabled = true;		
	}
	//alert(itemSelected.length);
}

function generateBarcode() {
	var a = itemSelected; 
	a = a.substring(0,itemSelected.length-1);
	window.open('/ittl/stock/barcode.do?mode=generateBarcode&item='+a);
}

function checkedAll(chk) {
	itemSelected = '';
	if( document.getElementById('all').checked == true) {
		  
		for (var i = 0; i < chk.length; i++) {
			chk[i].checked = true ;
			
			var item = "'"+chk[i].value+"'";
			itemSelected = itemSelected + item +",";
		}	
		document.getElementById('genBarcode').disabled = false;
	}else {
		for (var i = 0; i < chk.length; i++)
			chk[i].checked = false ;	
		document.getElementById('genBarcode').disabled = true;
	}
}


</script>
<script language="javascript">
				function checkItemSelected() {

					var radio = document.getElementsByName("checkboxValue");
					var checked = false;
					var radioValue = "";
					for(var i=0; i<radio.length; i++) {
						if(radio[i].checked) {
							checked = true;
							radioValue = radio[i].value;
						}
					}

					if (checked==true) {
						if(confirm('ยืนยันการเลือกข้อมูล: ' + radioValue)) {
							return true;
						}else {
							return false;
						}
					}else {
						alert("ต้องเลือก 1 รายการ");
						return false;
					}					
				}
			</script>

	
</head>

<body onload="document.getElementById('itemFind').focus();"><br />


<div id="wrapper">
	<!-- 
		<div id="header"><img src="images/kiuchilogo.png" width="305" height="80" /></div>
	 -->	 
	<div id="menu"><ul id="nav"></ul></div>
	  
	<div id="content">
		<div id="menuNav">			
			<a href="<%=request.getContextPath() %>/Login.do?mode=check" >หน้าหลัก</a> 			
		</div>		<br />

					
		<div >	
	 
		<div>
		
		<table border="1" width="90%">
		 
			
			<tr class="odd">
				<td colspan="9" > 
					<html:form action="/chemicalpo.do">
						<input type="hidden" name="dept" value="${dept}" />
						<html:submit property="mode" style="width:100%;height:50px">
							<bean:message key="chemicalpoForm.cal"/>
						</html:submit>
					</html:form>				

				</td>			
			</tr>			
			<tr class="odd">
				<td colspan="8" > &nbsp;
				</td>			
			</tr>						
		<html:form action="/chemicalpo.do">
			<input type="hidden" name="dept" value="${dept}" />				
			
			<tr class="odd">
											
				<td colspan="9" > 
					<logic:notEmpty name="itemResults">
						<html:submit property="mode" style="width:100%;height:50px" styleId="btnCreatepo" onclick="return checkItemSelected(); ">
							<bean:message key="chemicalpoForm.createpo"/>
						</html:submit>
					</logic:notEmpty>
					<logic:empty name="itemResults">
						<html:submit property="mode" style="width:100%;height:50px" styleId="btnCreatepo" disabled="true" >
							<bean:message key="chemicalpoForm.createpo"/>
						</html:submit>
					</logic:empty>					
				</td>								
			</tr>			
			
			<tr class="odd">
				<td width="20">No.</td>
				<td></td>				
				<td width="150" >Code</td>
				<td width="250">Name</td>
				<td width="70">qty Stock</td>
				<td width="70">Min</td>
				<td width="70">qty Reserved</td>
				<td width="70">qty po</td>
				<td width="70">qty for order</td>				
			</tr>
			
			<logic:notEmpty name="itemResults">
				<logic:iterate id="var" name="itemResults" indexId="id">

						<tr onmouseover="this.className='menu-over'" 
							onmouseout="this.className='even'" class="even" id="r${id+1+offset }">
							<td width="20" >${id+1+offset }.</td>		
							<td width="20">
								<input 	type="radio" name="checkboxValue" 
										value="${var.itemCode }" id="cb${id+1+offset }" 
										  />								
							</td>
							<td width="150">${var.itemCode }</td>												
							<td width="250">${var.itemName }</td>					
							<td width="70">${var.stockQty }</td>
							<td width="70" align="right">&nbsp;
								${var.stockMin }								 
							</td>
							<td width="70" align="right">${var.qtyReserved } </td>
							<td width="70" align="right">${var.qtyOfPO } </td>
							<td width="70" align="right">${var.qtyForOrder } </td>
													
						</tr>
				</logic:iterate> 
			</logic:notEmpty>
			<tr class="odd"><td colspan="6">หากไม่พบ รหัสสีเคมี กรุณาติดต่อ ฝ่ายคลังพัสดุ เพื่อตรวจสอบรหัสสีเคมีในระบบ</td></tr>
		</html:form>
		</table>
		
		</div>
	</center>
	</div>				

<input type="hidden" value="${monthFind }" id="monthFindId">
<script type="text/javascript">

	var item2 = document.getElementById("monthFindId").value;	
	document.formSearch.monthFind[item2-1].selected=true;
	
</script>


</div>
</div>
</body>

</html:html>